import request from '@/utils/request'


export async function  getAdmins() {
    let res =  await request({
      url: '/Admins',
      method: 'get',
    })
    return res.data.value;
  }

export async function addAdmin (Admin) {
    let res = await request({
        url: '/Admins',
        method: 'POST',
        data: Admin
    })
    return res.data.value
}
    

 export function removeAdmin(id){
    return request({
      url: `/Admins/${id}`,
      method: 'delete'
    })
    // return  new Promise( async (resolve, reject) => {
    //   var index = datas.findIndex(e=>e.id==id);
    //   datas.splice(index,1);
    //   resolve();
    // });
  }
      // 验证是否整数
export function isInteger(rule, value, callback) {
  if (!value) {
    return callback(new Error('输入不可以为空'));
  }
  setTimeout(() => {
    if (!Number(value)) {
      callback(new Error('请输入正整数'));
    } else {
      const re = /^[0-9]*[1-9][0-9]*$/;
      const rsCheck = re.test(value);
      if (!rsCheck) {
        callback(new Error('请输入正整数'));
      } else {
        callback();
      }
    }
  }, 0);
}
export function updateAdmin(parking){
  return  request({  
    url: `/Admins(${parking.AdminId})`,
    method: 'put',
    data: parking
  })
}